package com.sctvcloud.zhaohua_sd.ui.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.os.Message;
import android.view.View;

import com.ruihang.generalibrary.ui.dialog.BaseDialogFragment;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.zhaohua_sd.R;

import static com.sctvcloud.zhaohua_sd.R.id.dia_pic_choice_shot;

/**
 * Created by Administrator on 2017/6/21 0021.
 */

public class PicChoiceDiaFragment extends BaseDialogFragment implements View.OnClickListener {
    private CustomFontTextView shot_cv;
    private CustomFontTextView pic_cv;
    private int type = 3;

    public static final int SHOT_TAG = 1;
    public static final int PIC_TAG = 2;
    public static final int TYPE_PIC = 1;
    public static final int TYPE_VIDEO = 2;
    public static final int TYPE_PIC_AND_VIDEO = 3;

    @Override
    protected int getContentRes() {
        return R.layout.dia_pic_choice_fragment;
    }

    @Override
    protected void initViews(Dialog dialog, Bundle savedInstanceState) {
        shot_cv = (CustomFontTextView) dialog.findViewById(dia_pic_choice_shot);
        pic_cv = (CustomFontTextView) dialog.findViewById(R.id.dia_pic_choice_pic);
        shot_cv.setOnClickListener(this);
        pic_cv.setOnClickListener(this);
    }

    public PicChoiceDiaFragment setType(int type) {
        this.type = type;
        return this;
    }

    @Override
    public void onResume() {
        super.onResume();
        switch (type) {
            case TYPE_PIC:
                shot_cv.setText(R.string.rebllion_phone1);
                break;
            case TYPE_VIDEO:
                shot_cv.setText(R.string.rebllion_phone2);
                break;
            default:
            case TYPE_PIC_AND_VIDEO:
                shot_cv.setText(R.string.rebllion_phone);
                break;
        }
    }

    @Override
    public void onClick(View v) {
        if (callBack != null) {
            Message message = new Message();
            if (v.getId() == R.id.dia_pic_choice_shot) {
                message.what = SHOT_TAG;
                dismissAllowingStateLoss();
            } else if (v.getId() == R.id.dia_pic_choice_pic) {
                message.what = PIC_TAG;
                dismissAllowingStateLoss();
            }
            callBack.onCallBackMsg(this, message);
        }
    }
}
